using System;
using System.Collections.Generic;
using System.Text;

using LibrErian.Interfaces.Data;
using LibrErian.Interfaces.Services;

using Microsoft.Practices.ObjectBuilder;

namespace LibrErian.Services
{
    public class ServiceBase : IService
    {
        private IDataManager dataManager;

        [Dependency]
        public IDataManager DataManager
        {
            set
            {
                dataManager = value;
            }
            get
            {
                return dataManager;
            }
        }

        public void StartDisconnectedSession()
        {
            dataManager = DataManager.GetDisconnectedManager();
        }

        public void EndDisconnectedSessionWithFlush()
        {
            dataManager.Flush();
            EndDisconnectedSessionWithoutFlush();
        }

        public void EndDisconnectedSessionWithoutFlush()
        {
            dataManager.Dispose();
            dataManager = null;
        }
    }
}
